package edu.mis.modules.roomStatus;

import edu.mis.model.RoomStatus;

import java.util.List;

/**
 * 权限服务类
 *
 */
public class RoomStatusService {
		/**
	 * 添加日志
	 * @param roomStatus
	 * @return
	 */
	public boolean saveRoomStatus(RoomStatus roomStatus){  //service命名建议完整，见名知意。如此处的saveRoomStatus，参数尽量用对象
		if(roomStatus.findRoomStatusByName(roomStatus.getStatusName())==null){ //此处为业务逻辑，写在service里，不要写在model里。判断是否权限名重复，
			return roomStatus.save();
		}else{
			return false;
		}
	}
	
	/**
	 * 修改日志
	 * @param roomStatus
	 * @return
	 */
	public boolean updateRoomStatus(RoomStatus roomStatus){
			if(roomStatus.findRoomStatusByName(roomStatus.getStatusName())==null){ //此处为业务逻辑，写在service里，不要写在model里。判断是否权限名重复，
			return roomStatus.update();
		}else{
			return false;
		}
	}
	
	/**
	 * 删除日志
	 * @param id
	 * @return
	 */
	public boolean deleteRoomStatusById(int id) {
		return RoomStatus.dao.deleteById(id);
	}
	
	/**
	 * 根据ID得到日志
	 * @param id
	 * @return
	 */
	public RoomStatus findRoomStatusById(int id) {
		return RoomStatus.dao.findById(id);
	}
	/**
	 * 查询所有权限
	 * @return
	 */
	public List<RoomStatus> findAllRoomStatus(){
		return RoomStatus.dao.findAll();
	}


}
